//
//  ITCNPAlertViewController.m
//  InduceTool
//
//  Created by 魏延龙 on 2020/9/2.
//  Copyright © 2020 魏延龙. All rights reserved.
//

#import "ITCNPAlertViewController.h"
#import <CNPPopupController/CNPPopupController.h>
@interface ITCNPAlertViewController ()

// 全局才能点击其他区域消失
@property (nonatomic, strong) CNPPopupController *popupController;

@end

@implementation ITCNPAlertViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupViews];
}

-(void)setupViews {
    UIButton *popBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [popBtn setTitle:@"弹框" forState:UIControlStateNormal];
    popBtn.frame = CGRectMake(50, 200, 100, 44);
    [self.view addSubview:popBtn];
    [popBtn addTarget:self action:@selector(startAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 100)];
    label.numberOfLines = 0;
    [self.view addSubview:label];
    
    label.text = @"具体支持样式查看 theme 属性";
}

-(void)startAction {
    // 有代理可以设置 这里没有演示
    
    UIView *tipView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 120, 100)];
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, 44)];
    label1.text = @"演示简单文本";
    [tipView addSubview:label1];
    
    CNPPopupController *popupController = [[CNPPopupController alloc] initWithContents:@[tipView]];
    popupController.theme = [CNPPopupTheme defaultTheme];
    popupController.theme.popupStyle = CNPPopupStyleActionSheet;
    popupController.theme.presentationStyle = CNPPopupPresentationStyleSlideInFromBottom;
    popupController.theme.cornerRadius = 4;
    popupController.theme.popupContentInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [popupController presentPopupControllerAnimated:YES];
}

@end
